// pages/policy/policy.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    flag:0
  },

  onLoad(){
    wx.showLoading({
      title: '加载中...',
    })
    let access_token = wx.getStorageSync('access_token')
    wx.request({
      url: 'https://baokang.wshoto.com/wx/newslist',
      data:{
        access_token:access_token,
        location:'zhengce',
        news_num:'-1'
      },
      success:(res)=>{
        console.log(res)
        if(res.data.code >= 500){
          app.getLogin().then(function(){
            console.log('二次登录。。。')
          })
        } 
        else if(res.data.code == 1){
          this.setData({
            newsList:res.data.list,
            flag:1
          })
        }
      },
      complete:(res)=>{
        wx.hideLoading()
      }
    })
  },
  toDetail(e){
    let news_id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '../news-details/news-details?news_id=' + news_id,
    })
  }
})